<?php
/*
 * class PB
 * google proto buffer 协议入口
 */

class PB {
    var $pb;
    var $proto;
    var $isInit=FALSE;
    function PB($proto){
	$this->proto=$proto;
	$this->pb=APP::ADP('serialization','pb');
    }
    function cls($clsName){
	if($this->isInit==FALSE){
	    $this->_init();
	}
	return APP::N($clsName);
    }
    function serialize(){
	return call_user_func_array(array($this->pb,'serialize'),func_get_args());
    }
    function unserialize(){
	return call_user_func_array(array($this->pb,'unserialize'),func_get_args());
    }
    function createCls(){
	return $this->pb->createCls($this->proto);
    }
    function _init(){
	$classPath = __APP__ . 'var' . __SEP__ . 'pb' . __SEP__.'cls'.__SEP__;
	$classHead = V('o:PB/CLASS_HEAD');
	require_once($classPath.$classHead.$this->proto.'.php');
    }
}
?>